<template>
  <el-row>
    <el-col :span="8">
      <div id="main1" style="width: 500px; height: 500px;"></div>
    </el-col>
    <el-col :span="8">
      <div id="main2" style="width: 500px; height: 500px;"></div>
    </el-col>
    <el-col :span="8">
      <div id="main3" style="width: 500px; height: 500px;"></div>
    </el-col>
  </el-row>
</template>

<script>

import * as echarts from 'echarts'

export default {
  name: "Echarts1",
  data() {
    return{

    }
  },
  mounted() {  //页面元素渲染之后触发

    // 历年受到行政处罚单位数量统计
    var chartDom1 = document.getElementById('main1');
    var myChart1 = echarts.init(chartDom1);
    var option1 = {
      title: {
        text: '历年受到行政处罚单位数量统计',
        left: 'center',
        textStyle: {
          fontsize: 50
        }
      },
      xAxis: {
        type: 'category',
        data: ['2017', '2018', '2019', '2020', '2021', '2022']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: [], //受到行政处罚单位
          type: 'line',
          smooth: true
        }
      ]
    };

    this.request.get("/echarts/get1").then(res =>{
      option1.series[0].data = [
        {name: "2017", value: res.data[0]},
        {name: "2018", value: res.data[1]},
        {name: "2019", value: res.data[2]},
        {name: "2022", value: res.data[3]},
        {name: "2021", value: res.data[4]},
        {name: "2022", value: res.data[5]},
      ]
      myChart1.setOption(option1);
    })

    // 历年经营异常单位数量统计
    var chartDom2 = document.getElementById('main2');
    var myChart2 = echarts.init(chartDom2);
    var option2 = {
      title: {
        text: '历年经营异常单位数量统计',
        left: 'center',
        textStyle: {
          fontsize: 50
        }
      },
      xAxis: {
        type: 'category',
        data: ['2017', '2018', '2019', '2020', '2021', '2022']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: [], //经营异常单位
          type: 'line',
          smooth: true
        }
      ]
    };

    this.request.get("/echarts/get2").then(res =>{
      option2.series[0].data = [
        {name: "2017", value: res.data[0]},
        {name: "2018", value: res.data[1]},
        {name: "2019", value: res.data[2]},
        {name: "2022", value: res.data[3]},
        {name: "2021", value: res.data[4]},
        {name: "2022", value: res.data[5]},
      ]
      myChart2.setOption(option2);
    })

    // 历年严重失信单位数量统计
    var chartDom3 = document.getElementById('main3');
    var myChart3 = echarts.init(chartDom3);
    var option3 = {
      title: {
        text: '历年严重失信单位数量统计',
        left: 'center',
        textStyle: {
          fontsize: 50
        }
      },
      xAxis: {
        type: 'category',
        data: ['2017', '2018', '2019', '2020', '2021', '2022']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: [], //严重失信单位
          type: 'line',
          smooth: true
        }
      ]
    };

    this.request.get("/echarts/get3").then(res =>{
      option3.series[0].data = [
        {name: "2017", value: res.data[0]},
        {name: "2018", value: res.data[1]},
        {name: "2019", value: res.data[2]},
        {name: "2022", value: res.data[3]},
        {name: "2021", value: res.data[4]},
        {name: "2022", value: res.data[5]},
      ]
      myChart3.setOption(option3);
    })

  }
}


</script>

<style scoped>

</style>